[script] Changing material type of multiple materials

I used a scipt in 3DSMax to fill my book cabinet and imported the GLB which worked pretty well.

The only thing is that every imported material is of the Plastic (transparent) type which is not really needed and slows down rendering a lot. Especially since there are around 500+ different book covers so also 500+ materials.

It looks like this:

I need a way to change all Cover_### to the material type ‘plastic’. There are also some other prefixes but for the script that wouldn’t really matter, I can change it.

While I’ve tried a few things I can’t get my head wrapped around the Python scripts yet but maybe someone can kick me in the right direction. Changing them all one by one takes a bit long… I started :wink:

1 Like

Hi,

After some tries, it seems that material’s type isn’t a parameter of the material’s node, then, the setValue() command can’t reach that spec.
A way to workaround could be to create a new node with ‘lux_plastic_simple’ and then copy the different node’s edges from the transparent plastic to the plastic simple one by one in the script. And finaly delete the plastic transparent. More textures you have, more edges you will have to remap.

I’m still a beginner in python too, someonelse would have a better solution maybe.

1 Like

Thanks for trying! It would be nice if you could just select multiple materials and right click and change the Material Type. I noticed that if I export to GLTF the materials always get imported as Plastic (transparent). Not sure what causes it, could be because I do a scene conversion to get the V-Ray materials to a more PBR kind of material via 3DSMax.

If the material’s type ain’t reachable with a setValue I reckon it might be faster in the end to do them all manually. Or I’ve to check if I can do a different way of importing the books so the material will be plastic. Not sure if that will work since mostly with other formats the material is ‘diffuse’ which is also not what I want.

Again, thanks for trying!

Hello Oskar.
(my answer comes late - but hope it helps)
The simple workaround is to select all material (that should be changed) in the project material list and then use RMB “select parts with material”. Now RMB on one of the selected parts in the scene tree - RMB - material - change material type. DONE!

Wow @marco.wodarz, that worked like a charm. Scene was on pause here so perfectly in time. It will also help a lot in future scenes since I notice a lot of imported models get the plastic (transparent) by default after import.

Must say I would like the option to be in the material part as well, that’s also where I looked for the option. The selection of parts with the materials is useful but if you want to change a material type it has not much to do with parts.

Plenty of space in this context menu for ‘change material type’:
image

Maybe @will.gibbons can make a little video about this ‘hidden’ feature, I’m sure it will save people time if they import FBX/GLB models a lot.

2 Likes

I thought I had. I know it makes an appearance in one of my courses, but I guess not on the YouTube channel. Hard to keep track!

1 Like